package com.example.demo.service.Impl;

import com.example.demo.bean.BaseFile;
import com.example.demo.bean.BaseFileExample;
import com.example.demo.bean.BaseUserRole;
import com.example.demo.bean.BaseUserRoleExample;
import com.example.demo.dao.BaseUserRoleMapper;
import com.example.demo.service.IBaseUserRoleService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.util.List;

@Service
public class BaseUserRoleServiceImpl implements IBaseUserRoleService {

    @Resource
    BaseUserRoleMapper userRoleMapper;


    @Override
    public List<BaseUserRole> query(Long id) {
        BaseUserRoleExample example = new BaseUserRoleExample();
        if (!StringUtils.isEmpty(id)) {
            example.createCriteria().andIdEqualTo(id);
        }
        List<BaseUserRole> list = userRoleMapper.selectByExample(example);
        return list;
    }

    @Override

    public String saveOrUpdate(BaseUserRole baseUserRole){
        if (baseUserRole.getId()!=null){
            userRoleMapper.insert(baseUserRole);
            return "更新成功";
        }else{

            userRoleMapper.updateByPrimaryKey(baseUserRole);
        }
        userRoleMapper.insert(baseUserRole);
        return "保存成功";

    }

    @Override
    public void deleteById(long id) {
        userRoleMapper.deleteByPrimaryKey(id);

    }
}
